package com.ruoyi.project.cltmanage.chargelist.controller;

import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.cltmanage.chargelist.service.IChargeListService;

import com.ruoyi.project.cltmanage.domain.CltCharge;

import com.ruoyi.project.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cltmanage/chargelist")
public class ChargeListController {
    @Autowired
    private IChargeListService iChargeListService;
    @PreAuthorize("@ss.hasPermi('cltmanage:chargelist:list')")
    @GetMapping("/update/{paintId}/{type}")
    public AjaxResult update(@PathVariable String paintId , @PathVariable String type){
        int  dctCharges= iChargeListService.update(paintId, type);
        return AjaxResult.success(dctCharges);
    }

    @PreAuthorize("@ss.hasPermi('cltmanage:chargelist:list')")
    @GetMapping("/select/{id}")
    public AjaxResult select(@PathVariable String id ){
        List<CltCharge>  dctCharges= iChargeListService.select(id);
        return AjaxResult.success(dctCharges);
    }

    @PreAuthorize("@ss.hasPermi('cltmanage:chargelist:list')")
    @GetMapping("/selectOne")
    public AjaxResult selectOne(SysUser sysUser){
        List<CltCharge> dctCharges= iChargeListService.selectOne(sysUser.getNickName(),sysUser.getUserName());
        return AjaxResult.success(dctCharges);
    }
    @PreAuthorize("@ss.hasPermi('cltmanage:chargelist:list')")
    @GetMapping("/selectAll")
    public AjaxResult selectAll(){
        List<CltCharge> dctCharges= iChargeListService.selectAll();
        return AjaxResult.success(dctCharges);
    }
}
